<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%String lapasId = "LoadNewSNPWithBeadChooseFile";%>
<%@include file="Header.jsp"%>


<%//test new session
            response.setHeader("Cache-Control", "no-store");
            if (tmpHttpSessObj.getCurrentUser() == null) {
                pageContext.forward(response.encodeURL("./LogIn.jsp"));
                return;
            }

// check permissions
            if (!tmpHttpSessObj.isPowerUserWetUp()) {%>
<script  type="text/javascript" language="javascript">
    window.onload = disableAllButBack;
</script>
<br><a class="largest">Sorry, you do not have permission to use this page. </a><input type='button' onclick='history.go(-1);' name="badPermGoBack" value="Back" /><br><br>
Your privilege level is: <%=tmpHttpSessObj.getCurrentUser().getRightsReadable()%>.
To see the privileges associated with each level <input type="button" class="button" name="getPermissionDoc" onclick="openPermissionsDoc()" value="Click here"/> <br><br>
<br><br>
<% }%>


<%
            tmpHttpSessObj.clearInvalidField();
//test new session
            if (tmpHttpSessObj.getCurrentUser() == null) {
                pageContext.forward(response.encodeURL("./LogIn.jsp"));
                return;
            }

%>
<script language="JavaScript">

    function checkFormat(){
        var file = document.getElementById("fileToLoad");
        if(file.value.substring(file.value.length-4) == '.txt') {
            return true;
        }
        else { //Wrong filetype!
            alert("Error: Import file must be a .txt file.");
            var file = file.value="";
            return false;
        }
    }

    function gotoIndex(){
        if (checkSubmitFlag()) {
            window.location.assign(
            "<%=response.encodeURL("./Index.jsp")%>");
        }
    }
</script>

<%
            tmpHttpSessObj.clearInvalidField();
%>

<html>
    <form method="POST" name="searchForm" ENCTYPE="multipart/form-data"
          action="<%=response.encodeURL("./LoadNewSNPWithBeadCheckFile.jsp")%>"
          onsubmit="return checkFormat();">
        <table class="navigate">
            <tr>
                <td class="left" align="left" colspan="2"><a class="largest">Populate Database with BeadStudio Generated CSV Files</a></td>
            </tr>

        </table>
        <table class="instructions">
            <tr><td>
                    This tool will populate the database shared by SLIMS, Genapha, and Investigator Services from several files you prepared.
                    <br>
                    The files you will be uploading are described below. Most of them are generated by BeadStudio and require little effort
                    on your part. </td></tr>
            <tr><td>Your files must be CSV (comma separated) files and <u>every line must have a value for each of the
                        following fields</u>. (See below for what to enter if the field is unknown or blank.)
                </td></tr>
            <tr><td><b>The first line will be omitted to account for column headers!</b></td></tr></table><br><br>
        <fieldset>
            <table class="navigate" style="">
                <tr><th colspan="2">1. SNP_Table File (BeadStudio Generated)</th></tr>
                <tr><td colspan="2">Please ensure that the following fields are in the specified column. Errors will occur if the columns do not match.</td></tr>
                <tr><td>Name/RS number</td><td>The RS number of the SNP. Note: 'rs' will be prepended to the column data if it doesn't already exist.
                        Should be in the <b>5th (E) column.</b></td></tr>
                <tr><td>Chromosome number</td><td>The corresponding chromosome number. Should be in the <b>6th (F) column.</b></td></tr>
                <tr><td>Position</td><td>The position of the SNP. Should be in the <b>7th (G) column.</b></td></tr>
            </table>
            <table class="spaced" style=""><tr>
                    <td style="font-weight:bold">Select a file:
                        <input class="button" type="file" name="snpToLoad">
                    </td>
                </tr>

            </table>

        </fieldset>
        <br/>
        <fieldset>
            <table class="navigate">
                <tr><th colspan="2">Subject-Sample file (Self-made)</th></tr>
                <tr><td>Cohort</td><td>(ex: CAPPS or SAGE). The cohort name must already exist in the database; for existing cohorts, see the supporting data page.
                        If you want to use a new cohort, it will need to be created by an admin user.</td></tr>
                <tr><td>Subject ID</td><td>Subject's ID within its cohort, ie "1001-1" (not Az1001-1)</td></tr>
                <tr><td>Family ID</td><td>The subject's family ID within its cohort, ie "1001" or "0" if N/A</td></tr>
                <tr><td>Gender</td><td>The gender of the subject. Acceptable inputs are variations of "male" or "female".
                        For example: If the subject is male, then "male" or "m" are acceptable (NOT case sensitive).
                        "0" if the gender is unknown.</td></tr>
                <tr><td>Consent</td><td>Whether we have consent from this subject or not ("y" or "n"). "0" if unknown.</td></tr>
                <tr><td>Mother ID</td><td>Mother's ID within its cohort, ie "1001-4" or "0" if N/A</td></tr>
                <tr><td>Father ID</td><td>Mother's ID within its cohort, ie "1001-5" or "0" if N/A</td></tr>
                <tr><td>Ethnicity</td><td>For existing ethnicities, see the supporting data page. If you want to use a new ethnicity, it will need to be created by an admin user. </td></tr>
                <tr><td>Comments</td><td>"0" if none. (must not contain any apostrophes.)</td></tr>
                <tr><td>Geneva(Corresponding ID) ID</td><td>The ID of the genotyped subject, usually used internally by the genotyping center.</td></tr>
                <tr><td>Geneva Duplicate ID</td><td>Optional. Can be left blank if no such ID exists</td></tr>
            </table>
            <table class="spaced" style=""><tr>
                    <td style="font-weight:bold">Select a file:
                        <input class="button" type="file" name="subjectToLoad" >
                    </td>
                </tr></table>

        </fieldset>
        <br/>
        <fieldset>
            <table class="navigate">
                <tr><th colspan="2">3. Samples_Table File (Partially BeadStudio generated, require additional information)</th></tr>
                <tr><td colspan="2">Please ensure that the following fields are in the specified column. Errors will occur if the columns do not match.</td></tr>
                <tr><td>CIDR Name</td><td>
                        The name used to match up the Subjects with the Samples. Should match up with the Geneva ID of the corresponding subject.
                        This should be the <b>4th (D) column.</b></td></tr>
                <tr><td>Sample Name</td><td>The name of the sample. This shouild be in the <b>5th (E) column.</b></td></tr>
                <tr><td>Sample Type</td><td>The type of biological material this sample is or was extracted from (ie blood, epithelial etc). For existing sample types, see the supporting data page. If you want to use a new sample type, it will need to be created by an admin user.
                        This should be the <b>11th (K) column.</b></td></tr>
                <tr><td>Container Name</td><td>The name of the container that holds this sample. This should be the <b>18th (Q) column.</b></td></tr>
                <tr><td>Sample Plate Well Number</td><td>The well position this sample is located in with. The format is [row-letter][column-number] such as 'A01'. This should be the <b>19th (R) column.</b></td></tr>
                <tr></tr>
                <tr><td colspan="2">These last 4 columns are additional information that are required and the information does not come with BeadStudios. Please fill in the additional 4 columns.</td></tr>
                <tr><td>Container Type ID</td><td>For existing container types, see the supporting data page. If you want to use a new container type, it will need to be created by an admin user.
                        This is in the <b>31st (AF) column.</b></td></tr>
                <tr><td>Concentration</td><td>The concentration of the content in ng/ul, -1 for unknown. This is in the <b>32nd column (AG).</b></td></tr>
                <tr><td>Volume</td><td>The volume of the content in ul, -1 for unknown, 0 for empty. This is in the <b>33rd column (AH).</b></td></tr>
                <tr><td>Material Type ID</td><td>The ID of the type of material this content is (WGA, genomic, unextracted, etc). For existing material types, see the supporting data page. If you want to use a new material type, it will need to be created by an admin user.
                        This is in the <b>34th column (AI).</b></td></tr>
            </table>
            <table class="spaced" style=""><tr>
                    <td style="font-weight:bold">Select a file:
                        <input class="button" type="file" name="sampleToLoad" id="sampleToLoad">
                    </td>
                </tr></table>
            <table class="spaced"><tr><td><input class="button" type="submit" value="Next"></td>
                    <td>
                        <input class="button" type="button" value="Cancel" onclick="return gotoIndex();"></td>
                </tr></table>


        </fieldset>
    </form>

</html>

<%@include file="Footer.jsp"%>
